<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Popover - Standalone</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
    />
    <link href="../../../../../css/core.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
  </head>
  <script type="module">
    import { popoverController } from '../../../../dist/ionic/index.esm.js';
    window.popoverController = popoverController;
  </script>
  <body>
    <main>
      <button class="expand" id="basic-popover" onclick="presentPopover({ component: 'profile-page', event: event })">
        Show Popover
      </button>
      <button
        class="expand"
        onclick="presentPopover({ component: 'translucent-page', event: event, translucent: true })"
      >
        Show Translucent Popover
      </button>
      <button class="expand" color="secondary" onclick="presentPopover({ component: 'list-page', event: event })">
        Show Long List Popover
      </button>
      <button class="expand" color="danger" onclick="presentPopover({ component: 'profile-page' })">
        No Event Popover
      </button>
    </main>

    <script>
      async function presentPopover(opts) {
        const popover = await popoverController.create(opts);
        await popover.present();
      }

      class ProfilePage extends HTMLElement {
        constructor() {
          super();
        }

        connectedCallback() {
          this.innerHTML = `
          <ion-content>
            <ion-list>
              <ion-list-header><ion-label>Ionic</ion-label></ion-list-header>
              <ion-item><ion-label>Item 0</ion-label></ion-item>
              <ion-item><ion-label>Item 1</ion-label></ion-item>
              <ion-item><ion-label>Item 2</ion-label></ion-item>
              <ion-item><ion-label>Item 3</ion-label></ion-item>
            </ion-list>
          </ion-content>
        `;
        }
      }

      customElements.define('profile-page', ProfilePage);

      class ListPage extends HTMLElement {
        constructor() {
          super();
        }

        connectedCallback() {
          let items = '';
          for (var i = 0; i < 30; i++) {
            items += '<ion-item><ion-label>Item ' + i + '</ion-label></ion-item>';
          }

          this.innerHTML =
            `
          <ion-content>
            <ion-list>
              <ion-list-header><ion-label>Ionic</ion-label></ion-list-header>
              ` +
            items +
            `
            </ion-list>
          </ion-content>
        `;
        }
      }

      customElements.define('list-page', ListPage);

      class TranslucentPage extends HTMLElement {
        constructor() {
          super();
        }

        connectedCallback() {
          this.innerHTML = `
          <div class="ion-padding">
            <h1>Translucent Popover</h1>
          </div>
        `;
        }
      }

      customElements.define('translucent-page', TranslucentPage);
    </script>
  </body>
</html>
